package com.qf.rabbitmqspringboot.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类
 * @author zjw
 */
@Configuration
public class RabbitMQConfig {


    /**
     * 创建交换机
     * @return
     */
    @Bean
    public Exchange exchange(){
        return ExchangeBuilder.fanoutExchange("boot_exchange").build();
    }

    /**
     * 创建队列
     * @return
     */
    @Bean
    public Queue queue(){
        return QueueBuilder.durable("boot_queue").build();
    }

    /**
     * 绑定
     */
    @Bean
    public Binding binding(Queue queue,Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("").noargs();
    }
}
